package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	ItemCategoryEventNew           = "wms.ItemCategoryNew"
	ItemCategoryEventBeforeCreate  = "wms.ItemCategoryBeforeCreate"
	ItemCategoryEventBeforeUpdate  = "wms.ItemCategoryBeforeUpdate"
	ItemCategoryEventBeforeSave    = "wms.ItemCategoryBeforeCreate wms.ItemCategoryBeforeUpdate"
	ItemCategoryEventAfterCreate   = "wms.ItemCategoryAfterCreate"
	ItemCategoryEventAfterUpdate   = "wms.ItemCategoryAfterUpdate"
	ItemCategoryEventAfterSave     = "wms.ItemCategoryAfterCreate wms.ItemCategoryAfterUpdate"
	ItemCategoryEventDelete        = "wms.ItemCategoryDelete"
	ItemCategoryAccessControlEvent = "wms.ItemCategoryAccessControl"
)

func GetItemCategoryConfig() *mgo.DocConfig {
	return ItemCategory_Config
}

var ItemCategory_Config *mgo.DocConfig

func init() {
	ItemCategory_Config = NewItemCategoryConfig()
}
func NewItemCategoryConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "wms.ItemCategory",
		Fields: []string{
			"name", "code", "note", "sort", "l", "r", "level", "link", "parent", "children",
		},
		RelationFields: []string{
			"parent", "children",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"parent": {
				Config:     GetItemCategoryConfig,
				DocName:    "ItemCategory",
				JoinType:   "O",
				KeyInside:  "parentId",
				KeyOutSide: "id",
			},
			"children": {
				Config:     GetItemCategoryConfig,
				DocName:    "ItemCategory",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "parentId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
